<?php
include '../../public/index.php';
$request = json_decode(file_get_contents('php://input'), true);
$start = $request["pageSize"] * ($request["page"]-1);
if (empty($request)) {die(json_encode(array("code" => 1, "message" => "请传递page和pageSize参数")));}
$query = mysqli_query($connect, "select * from app_info limit {$start},{$request["pageSize"]};");
if (!$query) {mysqli_close($connect);die(json_encode(array("code" => 500, "message" => "服务器异常")));}
$query_count = mysqli_query($connect,"select count(*) as count from app_info");
if (!$query_count) {mysqli_close($connect);die(json_encode(array("code" => 500, "message" => "服务器异常")));}
$count=(int)mysqli_fetch_assoc($query_count)["count"];
$data = array();
while ($item = mysqli_fetch_assoc($query)) {$data[] = $item;}
$finalData = array("code" => 0, "data"=>$data, "total" => $count,"start"=>$start,"pagesize"=>$request["pageSize"]);
mysqli_close($connect);
die(json_encode($finalData));
